<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>卡片笔记(重置邮件)</title>
</head>

<body>
    <div class="main w980">
        <img src="http://cmsdev.mpcheshi.com:81/upload/images/20211130/54d6ed7ba8f1c10544bf598e300aed27.png" />
        <p>Hi,XXX昵称</p>
        <p>感谢使用卡片笔记!</p>
        <p>更换邮箱需要您的邮箱验证码，验证码有效期为15分钟。</p>
        <p>您的验证码为:</p>
        <div class="content">
            <p class='code' id="code"></p>
            <button class="btn" onclick="copy()">一键复制</button>
        </div>
        <textarea id="copy"></textarea>
        <p>*此邮件是自动生成的。请不要回应。如果您需要其他帮助，请联系我们。</p>
    </div>
</body>

</html>
<script language="javascript" type="text/javascript">
    function copy() {
        //获取p节点的文本
        let ctnt = document.getElementById('code').innerText;
        //为textarea的value赋值
        let copy = document.getElementById('copy');
        copy.value = ctnt;
        //调用选中，执行复制命令
        copy.select();
        document.execCommand('copy');
        //提示成功
        alert('拷贝成功！');
    }
</script>
<style>
    .w980 {
        width: 980px;
        margin: 40px auto;
    }

    a {
        cursor: pointer;
        color: #2cb9ef;
        text-decoration-line: none;
    }

    .btn {
        cursor: pointer;
        background-color: #4caf50;
        border: 2px solid #fff;
        padding: 8px 20px;
        color: #fff;
        border-radius: 5px;
    }

    .btn:hover {
        background-color: #fff;
        color: #4caf50;
        border: 2px solid #4caf50;
    }

    a:hover {
        text-decoration-line: underline;

    }

    .code {
        font-size: 36px;
        margin-right: 20px;
        color: #4caf50;
    }

    .content {
        width: 30%;
        display: flex;
        align-items: center;
        justify-content: space-around;
        border: 1px solid #c6c6c6;
    }

    #copy {
        position: absolute;
        left: -500px;
        top: -500%;
        opacity: 0;
        z-index: -10;
    }
</style>